package jaeger

import (
	"fmt"
	"github.com/opentracing/opentracing-go"
	"io"
)

var TracerCloser io.Closer

// InitTracer 初始化链路追踪实例
// serverName：服务名称
func InitTracer(serverName string) {
	if !Config.Enable {
		return
	}
	tracer, closer, err := NewTracer(serverName, Config.UdpAddr)
	if err != nil {
		panic(fmt.Sprintf("初始化jaeger链路追踪实例失败！%v", err))
	}
	TracerCloser = closer
	opentracing.SetGlobalTracer(tracer)
}
